/**
*/
Ext.namespace("Ext.clNameSpace");
Ext.clNameSpace.treeLoader = function(){
	Ext.clNameSpace.treeLoader.superclass.constructor.call(this);
	this.proxy = new Ext.data.ScriptTagProxy({
		url:this.dataUrl
	});
};
Ext.extend(Ext.clNameSpace.treeLoader,Ext.tree.TreeLoader,{
	dataUrl:'login/getdirjsontree.action'
});

Ext.clNameSpace.mainPanel = function(config){	
			/*
			var panel1 = new Ext.Panel({
				frame:true,
				baseCls:'x-plain',
				id:'panel1',
				title:'项目管理',
				width:400,
				height:200,
				html:'<img src=""></img>'
				
			});
			var panel2 = new Ext.Panel({	
				frame:true,
				baseCls:'x-plain',
				id:'panel2',
				title:'资源库',
				width:400,
				height:200,
				html:'<img src=""></img>'
			});
			var panel3 = new Ext.Panel({
				frame:true,
				baseCls:'x-plain',
				id:'panel3',
				title:'工程建设信息',
				width:400,
				height:200,
				html:'<img src=""></img>'
			});
			var panel4 = new Ext.Panel({
				frame:true,
				baseCls:'x-plain',
				id:'panel4',
				title:'图片照片处理软件',
				width:400,
				height:200,
				html:'<img src=""></img>'
			});
			*/
            var innerPanel = new Ext.Panel({  
                        frame:true,
                        baseCls:'x-plain',
                        id:'main_content',
                        region : 'center',  
                        margins : '5 0 0 0'/*,  
                        layout : 'table',
                        layoutConfig:{
							columns:2
						}, 
                        items : [panel1, panel2,panel3,panel4]  
                        */
                    });  
            var aWeek = ['星期天', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
            var currentTime = new Ext.Toolbar.TextItem('当前时间:'
            	+new Date().format('Y-m-d H:i:s') + '&nbsp;&nbsp;'
   				+ aWeek[new Date().getDay()]);
   			
   			
   			var loginUser = new Ext.Toolbar.TextItem('当前登录:');
   			
   			Ext.Ajax.request({
   				url:'login/getuser.action',
   				success:function(response,options){
   					var responseArray = Ext.util.JSON.decode(response.responseText);
   					//alert(responseArray.msg);
   					Ext.fly(loginUser.getEl()).update('当前登录:'+responseArray.msg);
   				}
   			});
   			
   			
            var northPanel = new Ext.Panel({  
                        //title : 'North Panel',  
                        region : 'north',  
                        height : 25,  
                        minSize : 75,  
                        maxSize : 250,  
                        baseCls:'x-plain',
						frame:true,
                        margins : '5 5 0 5',
                        
                        items:[
                        
                        	new Ext.Toolbar({	
                        		items:[
                        		
                        		'<a href="index.html">首页</a>',
                        		'->',
                        		currentTime,
                        		'-',
                        		
                        		loginUser,
                        		'-',
                        		'<a href="common/changepwd.html">修改密码</a>',
                        		'<a href="login.html">退出系统</a>'
                        		]
                        	
                        	})
                        	
                        	
                        ]  
                        
                    });  
           
            var westPanel = new Ext.tree.TreePanel({
            	id:'forum-tree',
            	region:'west',
            	title:'分类',
            	split:'true',
            	
				
            	width:200,
            	minSize : 100,  
                maxSize : 300,  
                collapsible:true,
                margins:'0 0 5 5',
                loader:new Ext.clNameSpace.treeLoader(),
                rootVisible:false,
                lines:false,
                autoScroll:true,
                root:new Ext.tree.AsyncTreeNode({
                	text:'分类',
                	expanded:true
                })
            });
                    /*
            var eastPanel = new Ext.Panel({  
                        title : 'East Panel',  
                        region : 'east',  
                        margins : '5 0 0 0',  
                        width : 200,  
                        minSize : 100,  
                        maxSize : 300,  
                        split : true,  
                        collapsible: true  
                    });
                    */  
	var _config = Ext.apply({
		 //title : 'Border Layout',  
         renderTo : 'main-div',  
         layout : 'border',  
         width : 1020,  
         height : 620,  
         items : [northPanel,westPanel,innerPanel]  
		
	},config);
	Ext.clNameSpace.mainPanel.superclass.constructor.call(this,_config);
	Ext.TaskMgr.start({
    run : function() {
     Ext.fly(currentTime.getEl()).update('当前时间：'
       + new Date().format('Y-m-d H:i:s') + '  '
       + aWeek[new Date().getDay()]);
    },
    interval : 1000
   });
   //单击左边栏
   function treeClick(node, e){
       if(node.isLeaf()){
       		var items = Ext.getCmp("main_content").items;
       		if(items != null){
       			for (var i = 0; i < items.getCount(); i=i+1)   
              		Ext.getCmp("main_content").remove(items.get(i)); 
       		}
       		var clfl = new Ext.clNameSpace.fileListPanel({
    		});
            Ext.getCmp("main_content").add(clfl);
    	    var _panel = Ext.getCmp("file_path");
    	   
    	    Ext.apply(_panel,{html:"<font size=2>"+node.parentNode.id+">"+node.id+"</font>"});
    	    curpath = node.parentNode.id+">"+node.id;
    	    var curr = node.parentNode.id+"\\"+node.id;
    	    Ext.Ajax.request({
    	    	url:"login/docurrentpath.action",
    	    	params:{
    	    		currentPath:curr
    	    	},
    	    	success:function(response,options){
    	    		Ext.getCmp("filepage_panel").store.reload();
    	    		clfl.show();
    	    		Ext.getCmp("main_content").doLayout();
    	    	}
    	    });
    	   
    	    
    	    
       }     
   }
   westPanel.on("click",treeClick);
   
};
Ext.extend(Ext.clNameSpace.mainPanel,Ext.Panel,{});

